#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 1e5 + 10, M = 3e5 + 10, M2 = M * 2;
int p[N];
int n, m, q;
int h[N], e[M2], ne[M2], w[M2], idx;
int depth[N], f[N][22];
int ans[N], dis[N][22];
bool st[N];
void add(int a, int b, int c)
{
	e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++;
}
struct node
{
	int a, b, w;
}S[M];
int find(int x)
{
	if (x != p[x])p[x] = find(p[x]);
	return p[x];
}
int cmp(node a, node b)
{
	return a.w > b.w;
}
void kruskal()
{
	sort(S + 1, S + m + 1, cmp);
	for (int i = 1; i <= n; i++)p[i] = i;
	for (int i = 1; i <= m; i++) {
		int a = S[i].a;
		int b = S[i].b;
		a = find(a);
		b = find(b);
		if (a != b) {
			//cout<<"S[i].a=="<<S[i].a<<"   S[i].b=="<<S[i].b<<endl;
			add(S[i].a, S[i].b, S[i].w);
			add(S[i].b, S[i].a, S[i].w);
			p[a] = b;
		}
	}
}
void dfs(int u, int fa)
{
	st[u] = 1;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (j == fa)continue;
		depth[j] = depth[u] + 1;
		dis[j][0] = w[i];
		f[j][0] = u;
		for (int k = 1; 1 << k <= depth[j]; k++) {
			f[j][k] = f[f[j][k - 1]][k - 1];
			dis[j][k] = min(dis[j][k - 1], dis[f[j][k - 1]][k - 1]);

		}
		dfs(j, u);
	}
}

int lca(int a, int b)
{
	int ans = 0x3f3f3f3f;
	if (depth[a] < depth[b])swap(a, b);
	int d = depth[a] - depth[b];
	for (int i = 0; d; i++) {
		if (d & 1) {
			ans = min(ans, dis[a][i]);
			a = f[a][i];
		}
		d /= 2;
	}
	if (a == b)return ans;
	//cout<<"ans=="<<ans<<endl;
	for (int i = 21; i >= 0; i--) {
		if (f[a][i] != f[b][i]) {
			ans = min(ans, dis[a][i]);
			ans = min(ans, dis[b][i]);
			a = f[a][i];
			b = f[b][i];
		}
	}
	return min(ans, min(dis[a][0], dis[b][0]));
}
int main()
{
	cin >> n >> m >> q;
	memset(h, -1, sizeof(h));
	memset(dis, 0x3f, sizeof(dis));
	for (int i = 1; i <= m; i++) {
		int a, b, w;
		scanf("%d%d%d", &a, &b, &w);
		S[i] = { a,b,w };
	}
	kruskal();
	for (int i = 1; i <= n; i++) {
		if (!st[i]) {
			depth[i] = 0;
			dfs(i, 0);
		}
	}
	// 	for(int i=h[1];~i;i=ne[i]){
	// 	    int j=e[i];
	// 	    cout<<"i--->j"<<" ==="<<j<<endl;
	// 	}
	while (q--) {
		int a, b;
		cin >> a >> b;
		//cout<<"p[a]=="<<p[a]<<"   p[b]==="<<p[b]<<endl;
		int a1 = find(a);
		int b1 = find(b);
		if (a1 != b1)cout << -1 << endl;
		else cout << lca(a, b) << endl;
	}
	return 0;
}